import {useStudentListStore} from '@/stores/useStudentList.js'
import { ref,  computed } from 'vue';  
import { useNotLogged } from "@/hooks/useNotLogged.ts"


export function useBound(){
	const sutdentStore = useStudentListStore();
	const { isNotLogged, tipToLogin } = useNotLogged()
	const studentIsEmpt = computed(() => sutdentStore.students.length === 0)
	const tipBoundStudent = (isMock = false) => { // isMock  true:  是模拟数据，允许用户使用，直接放行，不作任何弹窗提醒 false : 非模拟数据，要根据真实情况判断是否允许用户使用
		console.log('是否真的调用了')
		if(isMock){
			return;
		}
		if(isNotLogged.value){
			 tipToLogin()
			 return;
		} 
		uni.showModal({
			title: '未绑定孩子设备',
			content: '您还未绑定孩子设备，暂时无法使用此功能，请先绑定！',
			cancelText:"先看看",
			confirmText:"去绑定",
			complete() {
				console.log('都会执行')
			},
			success: function (res) {
					if (res.confirm) {
						uni.navigateTo({
							url:"/pagesA/addChildDevices/index"
						})
					} else if (res.cancel) {
						console.log('用户点击取消');
					}
				}
		})
	}
	return {
		studentIsEmpt,
		tipBoundStudent
	}
}